import Field from 'winged/utils/wt-model-field'

export default {
	title: '并发症',
	name: 'complication',
	tableName: 'complication',
	single: false,
	query: {
		method: 'GET',
		url: 'doctor/patient/complication',
		transfer: true,
		pagination: true,
		extraParams: [
			'case_id',
		]
	},
	count: {
		method: 'GET',
		url: 'doctor/patient/complication/count',
		transfer: true,
		extraParams: [
			'case_id',
		],
	},
	new: {
		method: 'POST',
		url: 'doctor/patient/complication',
		transfer: true,
		extraParams: [
			'case_id',
		]
	},
	update: {
		method: 'PUT',
		url: 'doctor/patient/complication',
		transfer: true
	},
	delete: {
		method: 'DELETE',
		url: 'doctor/patient/complication',
		transfer: true
	},
	id_field: {
		// 用于修改、删除操作的字段名
		name: 'complication_id',
		// id字段查询结果中的tableName默认为'id'
		// tableName: 'id'
	},
	fields: [
		{
		label: '并发症类型',
		type: Field.types.select,
		options: [
			{
				label: '围手术期并发症',
				value: 'PERIOPERATION'
			}, {
				label: '随访并发症',
				value: 'FOLLOW_UP'
			},
		],
		display: true,
		summary: true,
		formSize: 'small',
		name: 'complication_type',
		tableName: 'complicationType',
		rules: [
			{required: true, message: '请选择并发症类型',  }
		]
	},{
			label: '并发症名称',
			type: Field.types.autocomplete,
			multiple: false,
			display: false,
			dependingField: {
				name: 'complicationType',
				message: '请先选择并发症类型',
				paramName: 'type',
			},
			query: {
				url: 'doctor/patient/complication/type',
				method: 'GET',
				transfer: true,
				pagination: true,
				useAutoFilter: true,
				allowEmptyQuery: true,
				disableCache: true,
				extraParams: [
					'case_id',
					'type'
				],
				extraFormParams: [
					{
						tableName: 'complication_type',
						name: 'type'
					}
				],
				filterParam: 'complication',
				label: 'complication',
				value: 'complication',
				allowAdd: true,
				addMethod: 'POST',
				addParam: 'complication',
			},
			name: 'content',
			tableName: 'content',
			rules: [
				{required: true, message: '请选择并发症名称',  }
			]
		}, {
			label: '并发症名称',
			type: Field.types.text,
			display: true,
			summary: true,
			noSave: true,
			tableName: 'content'
		}, {
			label: '记录时间',
			type: Field.types.date,
			display: true,
			name: 'record_date',
			tableName: 'recordDate',
			rules: [
				{ type: 'date', required: true, message: '请选择记录时间', trigger: 'blur' }
			]
		},  {
			label: '备注',
			type: Field.types.textarea,
			display: true,
			name: 'comment',
			tableName: 'comment'
		}
	]
};